package main.java;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Text {
    public static void main(String[] args) {
        ApplicationContext context=new FileSystemXmlApplicationContext("H:\\spring-jdbc\\src\\applicationContext.xml");
        DataSource dataSource= (DataSource) context.getBean("dataSource");
        try {
            Connection connection=dataSource.getConnection();
            String spl="SELECT *from school_student";
            PreparedStatement preparedStatement = connection.prepareStatement(spl);
            System.out.println("asd");
            ResultSet resultSet=preparedStatement.executeQuery();
            while (resultSet.next()){
                System.out.println(resultSet.getObject(1));
            }


        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
